home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / PACKET / 7PLUSDLL / WIN7PLSR / WIN7PLUS.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-24  |  5.2 KB  |  119 lines

  1. '
  2. '
  3. ' WIN7PLUS -=- (c) Charlie McIver 1996
  4. ' Purple Computer Solutions
  5. '
  6. ' Requires use of 7PLUS.DLL, also by me!
  7. '
  8. '
  9. Declare Function Seven_Plus_Encode Lib "7plus.dll" (ByVal Filename As String, ByVal blocksize As Long, ByVal first_part As Integer, ByVal last_part As Integer, ByVal info As Integer, ByVal crmode As Integer) As Integer
  10. Declare Function seven_plus_process Lib "7plus.dll" (ByVal Filename As String, ByVal Path As String, ByVal Cleanup As Integer, ByVal override As Integer) As Integer
  11. Declare Function Seven_Plus_Version Lib "7plus.dll" () As Integer
  12. Declare Function seven_plus_extract Lib "7plus.dll" (ByVal Filename As String) As Integer
  13. Declare Function Seven_Plus_Do Lib "7plus.dll" (ByVal Arg As String, ByVal nStrLen As Integer) As Integer
  14.  
  15. Global strError(19) As String
  16. Global strErrorHeader As String
  17. Global strDataPath As String
  18.  
  19. 'Rewrites a default INI file
  20. 'Its done in a naughty way - we should use the real windows INI functions!
  21. Sub CreateNewINI ()
  22.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "FilePath", Format$(App.Path))
  23.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Cleanup", "1")
  24.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "ErrorHeader", "7+ reported an error: ")
  25.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error0", "No Error detected")
  26.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error1", "Write Error")
  27.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error2", "File not found")
  28.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error3", "7+ header not found")
  29.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error4", "File does not contain expected part")
  30.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error5", "7 + header Is corrupt")
  31.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error6", "No filename for extracting is defined")
  32.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error7", "invalid error report / correction / index file")
  33.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error8", "Max number of parts exceeded")
  34.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error9", "Bit 8 stripped")
  35.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error10", "User break in test_file()")
  36.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error11", "Error report generated")
  37.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error12", "Only one, or no error report to join")
  38.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error13", "Error report / cor file does not refer to the same original file")
  39.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error14", "Couldn't write 7PLUS.FLS")
  40.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error15", "Filesize of original file and the size reported in err/cor file not equal")
  41.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error16", "Correction not successful")
  42.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error17", "No CRC found in err / cor file")
  43.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error18", "Time stamp in metafile differs from that in the COR file")
  44.   Call INI_Set(App.Path + "\WIN7PLUS.INI", "Win7PLUS", "Error19", "Metafile already exists")
  45.   Close #l
  46. End Sub
  47.  
  48. Sub Main ()
  49.   Dim INIFIle As String: INIFIle = App.Path + "\WIN7PLUS.INI"
  50.  
  51.   'If the ini file does not exist, create it!
  52.   If File_Exist(App.Path + "\WIN7PLUS.INI") = False Then Call CreateNewINI
  53.   strDataPath = ini_get(App.Path + "\WIN7PLUS.INI", "SevenPlus", "FilePath")
  54.  
  55.   'Load all the error message (they might be in french! - if anyone will translate!)#
  56.   strErrorHeader = ini_get(INIFIle, "SevenPlus", "ErrorHeader")
  57.   For j = 0 To 19
  58.     strError(j) = ini_get(INIFIle, "SevenPlus", "Error" + Format(j))
  59.   Next j
  60.   
  61.   'IF no Command Line Parameters are given, go on, else behave like normal 7+
  62.   If Command = "" Then
  63.     
  64.     'Show the main window
  65.     frmMain.Show
  66.   
  67.     'Set the Cleanup box and load the data path
  68.     If ini_get_int(INIFIle, "SevenPlus", "Cleanup") Then frmMain.chkCleanup.Value = 1
  69.  
  70.   Else
  71.     'Behave exactly like normal old 7+ for DOS
  72.     'All I do is simply pass a sting to the DLL function Seven_Plus_Do
  73.     Dim CLParams As String, temp As String
  74.     CLParams = Command + Chr(0)
  75.  
  76.     'Change directory?
  77.     If InStr(UCase(Command), "-D") > 0 Then
  78.       ChDrive (strDataPath)
  79.       ChDir (strDataPath)
  80.     End If
  81.     
  82.     'Run 7+ and report any error
  83.     f = Seven_Plus_Do(CLParams, Len(CLParams))
  84.     If f <> 0 Then MsgBox strErrorHeader + Chr(10) + strError(f)
  85.     
  86.     'Terminate
  87.     End
  88.   End If
  89. End Sub
  90.  
  91. Sub SplitSpacedText (strLine, strField(), nFields)
  92.   n = 0
  93.   Do
  94.     a = InStr(strLine, " ")
  95.     'If a the first char is a space this will cause an error (it could be double spaced)!
  96.     Select Case a
  97.     Case 0
  98.       strLine = ""
  99.       strField(n) = strLine
  100.     Case 1
  101.       strLine = Mid(strLine, 2)
  102.  
  103.     Case Else
  104.       strField(n) = Left(strLine, a - 1)
  105.       strLine = Mid(strLine, a + 1)
  106.       n = n + 1
  107.       ReDim Preserve strField(n)
  108.     End Select
  109.  
  110.   Loop Until a = 0
  111.   nFields = n
  112. End Sub
  113.  
  114. Sub Status (Status_Text As String)
  115.   frmMain.pnlStatus = Status_Text
  116.   frmMain.Timer.Interval = 1500
  117. End Sub
  118.  
  119.